﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;

namespace Besture.UI
{
    public class Global : System.Web.HttpApplication
    {
        Random rd = null;
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            rd = new Random();
            EUCPComm comm = EUCPComm.GetInstance();
            comm.mySmsContent += new EUCPComm.deleSQF(comm_mySmsContent);
            comm.mySmsReport += new EUCPComm.delegSMSReport(comm_mySmsReport);
            comm.mySmsReportEx += new EUCPComm.delegSMSReportEx(comm_mySmsReportEx);
        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

        }

        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started

        }

        void Session_End(object sender, EventArgs e)
        {
            // Code that runs when a session ends. 
            // Note: The Session_End event is raised only when the sessionstate mode
            // is set to InProc in the Web.config file. If session mode is set to StateServer 
            // or SQLServer, the event is not raised.

        }

        void comm_mySmsReportEx(string seq, string mobile, string errorCode, string serviceCodeAdd, string reportType, ref int flag)
        {
            GlobalDate date = GlobalDate.GetDate();
            SMSReport report = new SMSReport();
            report.seq = seq;
            report.mobile = mobile;
            report.errorCode = errorCode;
            report.serviceCodeAdd = serviceCodeAdd;
            report.reportType = reportType;
            report.flag = flag;
            date.SMSReportList.Add(report);
        }

        void comm_mySmsReport(string mobile, string errorCode, string serviceCodeAdd, string reportType, ref int flag)
        {
            GlobalDate date = GlobalDate.GetDate();
            SMSReport report = new SMSReport();
            report.seq = "0";
            report.mobile = mobile;
            report.errorCode = errorCode;
            report.serviceCodeAdd = serviceCodeAdd;
            report.reportType = reportType;
            report.flag = flag;
            date.SMSReportList.Add(report);
        }

        void comm_mySmsContent(string mobile, string senderaddi, string recvaddi, string ct, string sd, ref int flag)
        {
            GlobalDate date = GlobalDate.GetDate();
            SMSContent content = new SMSContent();
            content.Mobile = mobile;
            content.Senderaddi = senderaddi;
            content.Recvaddi = recvaddi;
            content.Ct = ct;
            content.Sd = sd;
            content.Flag = flag;
            content.Id = System.DateTime.Now.Ticks + rd.Next(1, 100);
            date.SMSContentList.Add(content);
        }
    }
}
